Skip to content

fix(webdav): register chi REPORT method in init to avoid race with settings#2712

Merged
rhafer merged 1 commit into
opencloud-eu:mainfrom
SAY-5:fix/settings-service-init-2686
May 13, 2026
Merged

fix(webdav): register chi REPORT method in init to avoid race with settings#2712
rhafer merged 1 commit into
opencloud-eu:mainfrom
SAY-5:fix/settings-service-init-2686

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented May 5, 2026

Description

Move chi.RegisterMethod("REPORT") from webdav.NewService into a package init() so it runs before any service goroutine is started by the suture supervisor.

Related Issue

Motivation and Context

chi.RegisterMethod mutates the package-global methodMap in github.com/go-chi/chi/v5, which (*node).setEndpoint iterates during route insertion. opencloud starts many services concurrently under suture, so calling RegisterMethod inside NewService could race with another service's mux.Route(...) and trigger a "concurrent map iteration and map write" fatal (the stack in #2686). Doing it in init() happens during package import, before any supervised goroutine starts. chi.RegisterMethod is idempotent so it stays safe.

How Has This Been Tested?

  • go build ./... and gofmt on the affected package pass.
  • go test -race ./services/webdav/pkg/service/v0/... builds cleanly under the race detector.

I do not have a deterministic local reproducer for the intermittent panic, but the race is visible in the chi source (a package-global map written by RegisterMethod and iterated by setEndpoint).

Screenshots (if appropriate):

n/a

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added (changelog entry)

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 12, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown
Member

@rhafer rhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks good to me. Please just remove the changelog file from the PR.

Thanks for making the effort to look into this bug!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this file. We don't use actively use the changelog files anymore. The commit message is good enough.

I think the changelog directory is still there by accident. I'll create a PR to remove that.

@SAY-5
Copy link
Copy Markdown
Contributor Author

SAY-5 commented May 12, 2026

Removed the changelog file in 274c067. Thanks for the review!

@SAY-5 SAY-5 force-pushed the fix/settings-service-init-2686 branch from 274c067 to 04b0402 Compare May 12, 2026 20:30
@SAY-5
Copy link
Copy Markdown
Contributor Author

SAY-5 commented May 12, 2026

Done, dropped the changelog file and rebased onto current main, so the PR is just the single service.go change now. Thanks for the review.

@rhafer rhafer merged commit 8b48501 into opencloud-eu:main May 13, 2026
61 checks passed
@openclouders openclouders mentioned this pull request May 13, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings Service crashes during HTTP server initialization with a Go runtime panic in chi route registration

2 participants